$(function () {

    // 修改用户名
    $('.aboutme .me th .changeusr').click(function () {
        $('.aboutme .hidden').css('display', 'block');
        $('.aboutme .hidden .cusr_page').css('display', 'block');
    });
    $('.aboutme .hidden .cusr_page .determine').click(function () {
        var value = $('.aboutme .hidden .cusr_page .usr_text').val();
        var error = $('.aboutme .hidden .cusr_page h3');
        var userid = $('.aboutme .me').attr('id');
        error.html('');
        if (value == null || value == '') {
            error.html('请输入用户名');
        } else {
            error.html('');
            window.location.href = "change?action=changeusr&userid=" + userid + "&username=" + value;
        }
    });
    $('.aboutme .hidden .cusr_page .cancel').click(function () {
        $('.aboutme .hidden').css('display', 'none');
        $('.aboutme .hidden .cusr_page').css('display', 'none');
    });

    // 修改密码
    $('.aboutme .me th .changepwd').click(function () {
        $('.aboutme .hidden').css('display', 'block');
        $('.aboutme .hidden .cpwd_page').css('display', 'block');
    });
    $('.aboutme .hidden .cpwd_page .cancel').click(function () {
        $('.aboutme .hidden').css('display', 'none');
        $('.aboutme .hidden .cpwd_page').css('display', 'none');
    });
    $('.aboutme .hidden .cpwd_page .determine').click(function () {
        var oldpwd = $('.aboutme .hidden .cpwd_page .oldpwd_text').val();
        var pwd = $('.aboutme .hidden .cpwd_page .pwd_text').val();
        var repwd = $('.aboutme .hidden .cpwd_page .repwd_text').val();
        var error = $('.aboutme .hidden .cpwd_page h3');
        var userid = $('.aboutme .me').attr('id');
        var flag = true;
        error.html('');
        if (oldpwd == null || oldpwd == '') {
            error.html('请输入原密码');
            flag = true;
            return;
        }
        if (pwd == null || pwd == '') {
            error.html('请输入新密码');
            flag = true;
            return;
        }
        if (repwd == null || repwd == '') {
            error.html('请再次输入密码');
            flag = true;
            return;
        }
        if (pwd != repwd) {
            error.html('两次输入密码不一致');
            flag = true;
            return;
        }
        if (flag) {
            error.html('');
            window.location.href = "change?action=changepwd&userid=" + userid + "&newpwd=" + repwd + "&oldpwd=" + oldpwd;
        }
    });
});